﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Doo_JetDAL;
using DoodJetView.Core;

namespace DoodJetView.VuesPartielles
{
    /// <summary>
    /// Logique d'interaction pour Permis_Form.xaml
    /// </summary>
    public partial class Permis_Form : UserControl
    {
        public Permis_Form()
        {
            InitializeComponent();
        }
        public Permis_Form(bool btn)
        {
            InitializeComponent();
            if (btn == false)
            {
                btn_cancel.Visibility = System.Windows.Visibility.Hidden;
                btn_save.Visibility = System.Windows.Visibility.Hidden;
                //.Visibility = System.Windows.Visibility.Hidden;
            }
        }
        public Permis_Form(bool btn,permis p)
        {
            InitializeComponent();
            if (btn == false)
            {
                btn_cancel.Visibility = System.Windows.Visibility.Hidden;
                btn_save.Visibility = System.Windows.Visibility.Hidden;
                //.Visibility = System.Windows.Visibility.Hidden;
            }
           numpermis.Text = p.numeroDePermis;
            if (p.isCotier > 0)
                 rbtn_cotier.IsChecked  =true;
            if (p.isHauturier > 0)
                rbtn_Hauturier.IsChecked  =true;
            if (p.isEauxInterieur > 0)
                rbtn_oInterieure.IsChecked  =true; 
            if (p.isPlaisance > 0)
                rbtn_PLaisance.IsChecked  =true;
             datePermis.SelectedDate =     DateTimeUnixTools.ConvertFromUnixTimestamp(p.dateObtentionPermis);
        }
        private void ClicksurBtnSave(object sender, RoutedEventArgs e)
        {
           //
        }

        public permis FromView()
        {
                int isC = (bool)rbtn_cotier.IsChecked ? 1 : 0;
                int isH = (bool)rbtn_Hauturier.IsChecked ? 1 : 0;
                int isE = (bool)rbtn_oInterieure.IsChecked ? 1 : 0;
                int isP = (bool)rbtn_PLaisance.IsChecked ? 1 : 0;
                permis news = new permis
                {
                    numeroDePermis = numpermis.Text,
                    isPlaisance = isP,
                    isHauturier = isH,
                    isCotier = isC,
                    isEauxInterieur = isE,
                    dateObtentionPermis = DateTimeUnixTools.ConvertToUnixTimestamp((DateTime)datePermis.SelectedDate)

                };
                return news;
            
        }
        

    }
}
